package org.familysearch.fsapi.gwt.common;

import com.google.gwt.core.client.GWT;

public class Logger {

	public static Logger getLogger(String name) {
		return new Logger(name);
	}

	String name;

	public Logger(String name) {
		this.name = name + " ";
	}

	public void debug(String message) {
		log("DEBUG " + message);
	}

	public <T> void debug(T t) {
		debug(t.toString());
	}

	public void error(Exception e) {
		error(e.toString(), e);
	}

	public void error(String message) {
		log("ERROR " + message);
	}

	public void error(String message, Exception e) {
		log("ERROR " + message, e);
	}

	public <T> void error(T t) {
		error(t.toString());
	}

	public void log(String message) {
		GWT.log(name + message);
	}

	public void log(String message, Throwable e) {
		GWT.log(message, e);
	}

	public void warn(String string) {
		log("WARN " + string);
	}
}
